<template>
	<view class='kapiang-list'>
		<!-- 商品列表组件 -->
		<view class='kapiang' v-for="(item, index) in commodityList" :key="index" @tap='goDetails(item.id)'>
			<image class='kapiang-img' :src="item.imgUrl" mode=""></image>
			<view class='kapiang-content'>
				<text class='kapiang-name'>{{ item.name }}</text>
				<view>
					<text class='price'>¥{{ item.price }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		commodityList
	} from '@/utils/index';
	export default {
		data() {
			return {
				commodityList: commodityList,
			}
		},
		methods: {
			goDetails(id) {
				uni.navigateTo({
					url: '../../pages/details/details?id=' + id + ''
				})
			}
		}
	}
</script>

<style scoped>
	.kapiang-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		width: 100%;
	}

	.kapiang {
		width: 50%;
		box-sizing: border-box;
		padding: 10px;
	}

	.kapiang-img {
		width: 100%;
		height: 200px;
		border: 1px solid yellowgreen;
		/* 添加圆角 */
		border-radius: 8px;
		/* 添加阴影效果 */
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
	}

	.kapiang-content {
		text-align: center;
	}

	.kapiang-name {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		/* 增加行数以容纳更多文本 */
		-webkit-line-clamp: 4;
		-webkit-box-orient: vertical;
		color: #333333;
		word-break: break-all;
		/* 调整内边距以提供更多空间 */
		padding: 2px 8px;
		font-size: 12px;
		/* 调整行高 */
		line-height: 1.2;
		/* 增加字间距 */
		letter-spacing: 0.3px;
	}
</style>